<template>
  <div class="unauthorized-container">
    <el-result
        icon="error"
        title="无权访问"
        sub-title="您没有权限访问该页面"
    >
      <template #extra>
        <el-button
            type="primary"
            @click="goToHome"
            class="home-button"
        >
          返回首页
        </el-button>
      </template>
    </el-result>
  </div>
</template>

<script setup>
import { useRouter } from 'vue-router';
const router = useRouter();
const goToHome = () => {
  const userType = localStorage.getItem('userType');
  const homePath = userType === 'student' ? '/student/dashboard' : '/researcher/dashboard';
  router.push(homePath);
};
</script>

<style scoped>
.unauthorized-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #f0f4ff 0%, #d9e0ff 100%);
  animation: gradientBG 15s ease infinite;
}

:deep(.el-result) {
  padding: 40px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  transform: scale(0.9);
  animation: scaleIn 0.5s ease-out forwards;
}

:deep(.el-result__icon) {
  transform: scale(1.2);
  margin-bottom: 24px;
  filter: drop-shadow(0 4px 6px rgba(255, 82, 82, 0.2));
}

:deep(.el-result__title) {
  color: #2c3e50;
  font-size: 28px;
  margin-bottom: 12px;
  font-weight: 600;
}

:deep(.el-result__subtitle) {
  color: #666;
  font-size: 16px;
  margin-bottom: 32px;
}

.home-button {
  padding: 12px 32px;
  border-radius: 8px;
  font-size: 16px;
  transition: all 0.3s ease;
  background: #409eff;
  border: none;
}

.home-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(64, 158, 255, 0.4);
  background: #66b1ff;
}

@keyframes scaleIn {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes gradientBG {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

@media (max-width: 768px) {
  :deep(.el-result) {
    margin: 20px;
    padding: 24px;
  }

  :deep(.el-result__title) {
    font-size: 24px;
  }
}
</style>